<include file="public@header"/>
</head>
<body>
<div class="layui-fluid">
    <form method="post" class="layui-form js-ajax-form margin-top-20" action="{:url('route/addPost')}">
        <div class="layui-card">
            <div class="layui-card-header">{:lang('ADMIN_ROUTE_ADD')}</div>
            <div class="layui-card-body">
                <div class="layui-form-item">
                    <label for="input-full_url" class="layui-form-label">原始网址<span class="form-required">*</span></label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" id="input-full_url" name="full_url">
                        <a class="layui-btn layui-btn-xs" href="javascript:doSelectUrl();">选择规则</a>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="input-url" class="layui-form-label">显示网址<span class="form-required">*</span></label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" id="input-url" name="url">
                        <p class="layui-word-aux"><span id="url-vars"></span> url格式一般为list/:param1/:param2或 list-&lt;param1&gt;-&lt;param2&gt;
                        </p>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="input-status" class="layui-form-label">是否启用</label>
                    <div class="layui-input-block">
                        <select class="layui-input" name="status" id="input-status">
                            <option value="1">启用</option>
                            <option value="0">禁用</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="submit" class="layui-btn layui-btn-normal js-ajax-submit">{:lang('ADD')}</button>
                        <a class="layui-btn layui-btn-primary" href="{:url('Route/index')}">返回</a>
                    </div>
                </div>
            </div>                    
        </div>
    </form>
</div>

<include file="public@footer"/>

<script>
    function doSelectUrl() {
        var selectedCategoriesId = $('#js-categories-id-input').val();
        openIframeLayer("{:url('Route/select')}?ids=" + selectedCategoriesId, '请选择URL', {
            area: ['95%', '90%'],
            btn: ['确定', '取消'],
            yes: function (index, layero) {

                var iframeWin   = window[layero.find('iframe')[0]['name']];
                var selectedUrl = iframeWin.confirm();

                if (selectedUrl) {
                    $('#input-full_url').val(selectedUrl.action);
                    $('#input-url').val(selectedUrl.url);
                    var helpBlock = selectedUrl.vars ? "URL参数有" + selectedUrl.vars + ',' : '';
                    $('#url-vars').text(helpBlock);
                }
                layer.close(index); //如果设定了yes回调，需进行手工关闭
            }
        });
    }
</script>
